<template>
  <el-dialog :visible="value" :before-close="cancel">
    <template slot="title">
      设置虚拟代理账户
    </template>
    <el-form :model="form" ref="refForm" :rules="rules" label-width="120px" @submit.native.prevent>
      <el-form-item label="输入代理账户：" prop="proxyName">
        <el-input type="text"  v-model="form.proxyName"></el-input>
      </el-form-item>
      <el-form-item label="推广链接：" prop="remark">
        <span>默认关闭代理推广链接功能</span>
      </el-form-item>
      <el-form-item label="开通下级代理：" prop="remark">
        <span>默认关闭开通下级代理功能</span>
      </el-form-item>
      <el-form-item label="代理佣金：" prop="remark">
        <span>默认关闭代理佣金功能（不计算佣金）</span>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancel">取 消</el-button>
      <el-button type="primary" @click="submit('refForm')">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import {addMemberComment} from '@/services/api/member'
  import {form} from '@/build'

  export default {
    name: "virtual-agency-dialog",
    props: ['value', 'rowData'],
    mixins: [form],
    data(){
      return {
        form: {
          proxyName: '',
        },
        rules: {
          proxyName: [
            {required: true, message: '代理账户名不能为空'}
          ],
        },
      }
    },
    computed:{


    },
    methods: {
      cancel() {
        this.$emit('input',false)
      },
      submit(formName) {
        this.$refs[formName].validate((result, fields)=>{
          if (result) {
            this.$emit('submit',{...this.form,userType:'agency'});
            this.cancel();
          } else {
            // console.log('error submit!!');
            return false;
          }
        });

      }
    },
    mounted() {
      this.bindSave(addMemberComment, 'saveForm', 'formData', {
        successMessage:'保存成功',
        afterSuccess: ([result, data]) => {
          if (result) {
            this.$parent.gridSearch();
          }
          return data
        }
      });
    }
  }
</script>

<style scoped>

</style>
